// 添加取证信息
Vue.component('ht-show', {
    name:'ht-show',
    template: `
        <el-dialog title="" :visible.sync="show" 
            :destroy-on-close="true" width="90%" top="20px" @close="close" z-index="9999999">
            <el-form label-width="210px" :data="editData" size="mini" :inline="true">
                                    <el-form-item label="所属项目" >
                                        <el-select v-model="editData.project_id" filterable clearable>
                                            <el-option :value="item.id" :label="item.title"
                                                       v-for="item in projectList" :key="item.id"></el-option>
                                        </el-select>
                                    </el-form-item>

                                    <el-form-item label="来源" >
                                        <el-select v-model="editData.is_online" filterable clearable>
                                            <el-option :value="1" label="线上" ></el-option>
                                            <el-option :value="-1" label="线下" ></el-option>
                                            <el-option :value="2" label="民事行政" ></el-option>
                                            <el-option :value="3" label="刑事" ></el-option>
                                        </el-select>
                                    </el-form-item>

                                    <el-form-item label="公证日期" >
                                        <el-date-picker
                                                v-model="editData.gong_time"
                                                type="date"
                                                format="yyyy-MM-dd"
                                                value-format="yyyy-MM-dd"
                                                placeholder="选择日期">
                                        </el-date-picker>
                                    </el-form-item>



                                    <el-form-item label="地区" >
                                        <el-input type="text" placeholder="地区" v-model="editData.region"></el-input>
                                    </el-form-item>

                                    <el-form-item label="序号">
                                        <el-input type="text" placeholder="序号" v-model="editData.no"></el-input>
                                    </el-form-item>
                                    <el-form-item label="购买日期" >
                                        <el-date-picker
                                                v-model="editData.buy_day"
                                                type="date"
                                                format="yyyy-MM-dd"
                                                value-format="yyyy-MM-dd"
                                                placeholder="购买日期">
                                        </el-date-picker>
                                    </el-form-item>
                                    <el-form-item label="案由" >
                                        <el-input type="text" placeholder="案由" v-model="editData.why"></el-input>
                                    </el-form-item>

                                    <el-form-item label="案件来源">
                                        <el-input type="text" placeholder="案件来源" v-model="editData.source"></el-input>
                                    </el-form-item>

                                    <el-form-item label="店铺名称" >
                                        <el-input type="text" placeholder="店铺名称" v-model="editData.shop_title"></el-input>
                                    </el-form-item>

                            
                            <div class="main" v-for="(item,index) in editData.main" :key="item.id">
                                        <el-form-item label="证照">
                                            <el-input type="text" placeholder="证照" v-model="item.shop_card"></el-input>
                                        </el-form-item>
       
                                        <el-form-item label="主体名称">
                                            <el-input type="text" placeholder="主体名称" v-model="item.shop_name"></el-input>
                                        </el-form-item>
     
                                        <el-form-item label="注册地址/户籍地址">
                                            <el-input type="text" placeholder="注册地址/户籍地址" v-model="item.shop_address"></el-input>
                                        </el-form-item>
            
                                        <el-form-item label="经营者">
                                            <el-input type="text" placeholder="经营者" v-model="item.name"></el-input>
                                        </el-form-item>
      
                                        <el-form-item label="联系方式">
                                            <el-input type="text" placeholder="联系方式" v-model="item.tel"></el-input>
                                        </el-form-item>
     
                                        <el-form-item label="证件号码">
                                            <el-input type="text" placeholder="证件号码" v-model="item.id_card"></el-input>
                                        </el-form-item>

                            </div>
                                    <el-form-item label="发货/实际地址/处罚单位/案号" >
                                        <el-input type="text" placeholder="发货/实际地址/处罚单位/案号" v-model="editData.real_address"></el-input>
                                    </el-form-item>
                                    <el-form-item label="排" >
                                        <el-input type="text" placeholder="排" v-model="editData.sort"></el-input>
                                    </el-form-item>
                                    <el-form-item label="买" >
                                        <el-input type="text" placeholder="买" v-model="editData.buy"></el-input>
                                    </el-form-item>
                                    <el-form-item label="备注" >
                                        <el-input type="text" placeholder="备注" v-model="editData.bz"></el-input>
                                    </el-form-item>
            
            
                <el-form-item label="涉案产品">
                    <el-input type="text" placeholder="涉案产品" v-model="editData.goods"></el-input>
                </el-form-item>
                <el-form-item label="总价">
                    <el-input type="text" placeholder="总价" v-model="editData.buy_money"></el-input>
                </el-form-item>
                <el-form-item label="购买时间">
                    <el-input type="text" placeholder="购买时间" v-model="editData.buy_time"></el-input>
                </el-form-item>
                <el-form-item label="付款方式">
                    <el-input type="text" placeholder="付款方式" v-model="editData.buy_type"></el-input>
                </el-form-item>
                <el-form-item label="辅证/财产情况">
                    <el-input type="text" placeholder="辅证/财产情况" v-model="editData.other"></el-input>
                </el-form-item>
                <el-form-item label="订单编号" v-if="editData.is_online == 1">
                    <el-input type="text" placeholder="订单编号" v-model="editData.order_no"></el-input>
                </el-form-item>
                <el-form-item label="物流编号" v-if="itemData.is_online == 1">
                    <el-input type="text" placeholder="物流编号" v-model="editData.express_no"></el-input>
                </el-form-item>
                <el-form-item label="收货地址" v-if="itemData.is_online == 1">
                    <el-input type="text" placeholder="收货地址" v-model="editData.address"></el-input>
                </el-form-item>
                
                <el-form-item :label="editData.is_online == 1 ? '销量/现场情况' : '店铺规模/现场情况/罪名'">
                    <el-input type="text" :placeholder="editData.is_online == 1 ? '销量/现场情况' : '店铺规模/现场情况/罪名'" v-model="editData.shop_size"></el-input>
                </el-form-item>
                 <el-form-item label="案件类型" >
                    <el-select v-model="editData.item_type" filterable clearable>
                        <el-option value="大型案件" label="大型案件" ></el-option>
                        <el-option value="普通案件" label="普通案件" ></el-option>
                        <el-option value="辅证案件" label="辅证案件" ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="">
                    <el-button type="" @click="close">返回</el-button>
                </el-form-item>
            </el-form>
            <div class="ht-title" v-if="editData.project_id">其它材料</div>
            <div class="ht-main-body" v-if="editData.project_id">
                <ht-proof-table :project_id="editData.project_id" :project_item_id.sync="editData.id"></ht-proof-table>
            </div>
        </el-dialog>
    `,
    props: {
        itemData:{
            type:Object,
        },
        projectList:{
            type:Object,
        },
        show:{
            type:Boolean,
            default:false
        },
    },
    data() {
        return {
            proof:{},
            tableData:[],
            editData: {
                project_id:'',
                main:[
                    {shop_card:'',shop_name:'',shop_address:'',name:'',tel:'',send_address:''}
                ]
            }
        }
    },
    methods: {
        addMain() {
            this.editData.main.push({shop_card:'',shop_name:'',shop_address:'',name:'',tel:'',send_address:''})
        },
        delMain(index) {
            this.editData.main.splice(index,1)
        },
        doAdd(){
            let vs = this
            let url = "/admin/lawyer.project_item/addItem"
            if (vs.editData.id) {
                url = "/admin/lawyer.project_item/editItem"
            }
            Api.request(url,vs.editData).then(res=>{
                vm.showSuccessMsgCall(()=>{
                    vs.$emit('update:show',false)
                    vm.getData()
                })
            })
        },
        close(){
            this.$emit('update:show',false)
        },
    },
    watch: {
        itemData(v) {
            if (v) {
                this.editData = v
            }
        }
    }
})